# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=pango

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.36.3
pkgrel=1
pkgdesc="A library for layout and rendering of text (mingw-w64)"
arch=(any)
url="http://www.pango.org"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" 
    "${MINGW_PACKAGE_PREFIX}-freetype"
    "${MINGW_PACKAGE_PREFIX}-fontconfig"
    "${MINGW_PACKAGE_PREFIX}-cairo"
    "${MINGW_PACKAGE_PREFIX}-glib2"
    "${MINGW_PACKAGE_PREFIX}-harfbuzz" )
options=('staticlibs' 'strip')
source=("http://ftp.gnome.org/pub/gnome/sources/pango/${pkgver:0:4}/pango-${pkgver}.tar.xz"
    0001-no-unconditional-xft-please.all.patch
    0002-msvc-is-impotent-but-not.mingw.patch
    0006-give-cc-to-gir-scanner.mingw.patch
    0007-include-freetype.mingw.patch
    0008-allow-backend-selection.mingw.patch
    0009-pango_enable_static_build.patch
    0010-pangocairo-gir-add-cairo.patch)
sha256sums=('ad48e32917f94aa9d507486d44366e59355fcfd46ef86d119ddcba566ada5d22'
            '64e32bbf328cea85a4ea0a8552422eb74d4511f7655f19943302432ee67f36dc'
            '240d21474157c0deabc2660593ac0414565ddf30c304b08b74a09072c910b34d'
            'bb8bb6658ad71423aa2c94fdfec661406ee5a78909046a36136847a6ee1c9ac3'
            '7ad69d48bebd2640970ce7638a9d1b7f405816b70f914f3b544adf4da9b99dc5'
            '6afc8db8f19a043e569800137b985d4624029b3cb00ce4dbda02e656b1aa9885'
            '6bfe1e23894eb772f884e63b862935ddf53926f63e836af8712185415a0d27d9'
            '6cf99bc0a2fd44962a8a0152fff7f82c0b45d4fb2d3bb00a254b59f2c4f59d62')

prepare() {
  cd "$srcdir/pango-$pkgver"
  patch -p1 -i ${srcdir}/0001-no-unconditional-xft-please.all.patch
  patch -p1 -i ${srcdir}/0002-msvc-is-impotent-but-not.mingw.patch
  patch -p1 -i ${srcdir}/0006-give-cc-to-gir-scanner.mingw.patch
  patch -p1 -i ${srcdir}/0007-include-freetype.mingw.patch
  patch -p1 -i ${srcdir}/0008-allow-backend-selection.mingw.patch
  patch -p1 -i ${srcdir}/0009-pango_enable_static_build.patch
  patch -p1 -i ${srcdir}/0010-pangocairo-gir-add-cairo.patch
  
  autoreconf -fi
  sed -i 's/have_libthai=true/have_libthai=false/' configure
}

build() {
  CFLAGS+=" -mms-bitfields -I${MINGW_PREFIX}/include/cairo"
  CXXFLAGS+=" -mms-bitfields"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --with-included-modules=yes \
    --with-dynamic-modules=no \
    --enable-introspection \
    --disable-debug \
    --enable-shared \
    --enable-static
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
}
